﻿<%@ Page Title="Equipos" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true"
	CodeBehind="Default.aspx.cs" Inherits="TraceThisItem.WebUI.Teams.Default" %>

<asp:Content ID="Head" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Body" ContentPlaceHolderID="MainContent" runat="server">
	<asp:ScriptManager ID="ScriptManager1" runat="server">
	</asp:ScriptManager>
	<h2>
		Equipos
	</h2>
	<p>
		<asp:HyperLink NavigateUrl="~/Teams/Create.aspx" runat="server" Text="Crear equipo" /></p>
	<asp:UpdatePanel ID="UpdatePanel1" runat="server">
		<ContentTemplate>
			<div style="margin-bottom: 20px;">
				<asp:Label ID="labelMessage" runat="server" CssClass="bigFailureNotification"></asp:Label>
			</div>
			<div class="left-side stretch">
				<asp:GridView ID="TeamGridView" runat="server" Width="100%" AutoGenerateColumns="False"
					DataSourceID="TeamGridDataSoure" DataKeyNames="Id" OnSelectedIndexChanged="TeamGridView_SelectedIndexChanged">
					<SelectedRowStyle CssClass="selected-row" />
					<Columns>
						<asp:CommandField ButtonType="Image" ShowSelectButton="True" CancelImageUrl="~/Styles/Images/Edit_UndoHS.png"
							DeleteImageUrl="~/Styles/Images/DeleteHS.png" EditImageUrl="~/Styles/Images/EditInformationHS.png"
							SelectImageUrl="~/Styles/Images/GoToNextHS.png" UpdateImageUrl="~/Styles/Images/saveHS.png" />
						<asp:BoundField DataField="Id" HeaderText="Id" SortExpression="Id" />
						<asp:BoundField DataField="Name" HeaderText="Nombre" SortExpression="Name" />
						<asp:BoundField DataField="ProjectName" HeaderText="Proyecto" />
						<asp:TemplateField ShowHeader="False">
							<ItemTemplate>
								<asp:ImageButton ID="DeleteImageButton" runat="server" CausesValidation="False" CommandName="Delete"
									ImageUrl="~/Styles/Images/DeleteHS.png" Text="Eliminar" OnClientClick="return confirm('¿Está seguro que desea eliminar este equipo?')" />
							</ItemTemplate>
						</asp:TemplateField>
					</Columns>
				</asp:GridView>
				<asp:ObjectDataSource ID="TeamGridDataSoure" runat="server" DataObjectTypeName="TraceThisItem.Domain.Team"
					DeleteMethod="RemoveTeam" OnObjectCreating="TeamGridDataSoure_ObjectCreating"
					SelectMethod="GetTeams" TypeName="TraceThisItem.Domain.Facade" OnDeleting="TeamGridDataSoure_Deleting" />
			</div>
			<div class="right-side wide">
				<asp:DetailsView ID="TeamDetailsView" runat="server" Width="100%" AllowPaging="True"
					AutoGenerateRows="False" DataSourceID="TeamDetailsDataSoure" DataKeyNames="username"
					Visible="False" OnDataBound="TeamDetailsView_DataBound">
					<Fields>
						<asp:TemplateField HeaderText="Nombre de usuario:" SortExpression="UserName">
							<ItemTemplate>
								<asp:Label ID="Label1" runat="server" Text='<%# Bind("UserName") %>'></asp:Label>
							</ItemTemplate>
							<InsertItemTemplate>
								<asp:DropDownList ID="ddlUserToAdd" runat="server" Width="300px" DataSourceID="UserToAddDataSource"
									SelectedValue='<%# Bind("UserName") %>' DataTextField="FullName" DataValueField="UserName">
								</asp:DropDownList>
							</InsertItemTemplate>
							<HeaderStyle CssClass="details-header" />
							<ItemStyle Font-Italic="True" Width="70%" />
						</asp:TemplateField>
						<asp:TemplateField HeaderText="Nombre:" SortExpression="Firstname">
							<ItemTemplate>
								<asp:Label ID="Label2" runat="server" Text='<%# Bind("Firstname") %>'></asp:Label>
							</ItemTemplate>
							<InsertItemTemplate>
							</InsertItemTemplate>
							<HeaderStyle CssClass="details-header" />
						</asp:TemplateField>
						<asp:TemplateField HeaderText="Apellido:" SortExpression="Lastname">
							<ItemTemplate>
								<asp:Label ID="Label3" runat="server" Text='<%# Bind("Lastname") %>'></asp:Label>
							</ItemTemplate>
							<InsertItemTemplate>
							</InsertItemTemplate>
							<HeaderStyle CssClass="details-header" />
						</asp:TemplateField>
						<asp:TemplateField ShowHeader="False">
							<ItemTemplate>
								<asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" CommandName="Delete"
									Text="Remover usuario" OnClientClick="return confirm('¿Desea remover al usuario del equipo?')"></asp:LinkButton>
								<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" CommandName="New"
									Text="Agregar nuevo usuario"></asp:LinkButton>
							</ItemTemplate>
							<InsertItemTemplate>
								<asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="True" CommandName="Insert"
									Text="Insertar"></asp:LinkButton>
								&nbsp;<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" CommandName="Cancel"
									Text="Cancelar"></asp:LinkButton>
							</InsertItemTemplate>
						</asp:TemplateField>
					</Fields>
					<PagerSettings FirstPageImageUrl="~/Styles/Images/DataContainer_MoveFirstHS.png"
						LastPageImageUrl="~/Styles/Images/DataContainer_MoveLastHS.png" Mode="NextPreviousFirstLast"
						NextPageImageUrl="~/Styles/Images/DataContainer_MoveNextHS.png" PreviousPageImageUrl="~/Styles/Images/DataContainer_MovePreviousHS.png" />
				</asp:DetailsView>
				<asp:ObjectDataSource ID="TeamDetailsDataSoure" runat="server" OnObjectCreating="TeamDetailsDataSoure_ObjectCreating"
					SelectMethod="GetUsersByTeam" TypeName="TraceThisItem.Domain.Facade" OnInserting="TeamDetailsDataSoure_Inserting"
					OnDeleting="TeamDetailsDataSoure_Deleting" InsertMethod="AddUserToTeam">
					<SelectParameters>
						<asp:ControlParameter ControlID="TeamGridView" Name="teamId" PropertyName="SelectedValue"
							Type="Int32" />
					</SelectParameters>
				</asp:ObjectDataSource>
			</div>
			<asp:ObjectDataSource ID="UserToAddDataSource" runat="server" OldValuesParameterFormatString="original_{0}"
				OnObjectCreating="UserToAddDataSource_ObjectCreating" SelectMethod="GetUsersExceptFromTeam"
				TypeName="TraceThisItem.Domain.Facade">
				<SelectParameters>
					<asp:ControlParameter ControlID="TeamGridView" Name="teamId" PropertyName="SelectedValue"
						Type="Int32" />
				</SelectParameters>
			</asp:ObjectDataSource>
		</ContentTemplate>
	</asp:UpdatePanel>
</asp:Content>
